package ru.stepuk.modern.nodes;

import javax.swing.Icon;
import javax.swing.JDialog;
import ru.stepuk.modern.InvalidModelException;
import ru.stepuk.modern.Model;
import ru.stepuk.modern.Request;

/**
 *
 * @author ivan
 */
public abstract class Node {

    private static int count = 0;
    private int id;
    protected String name;
    protected Icon icon;
    protected Model model;

    public Node(Model model) {

        id = ++count;
        name = "Unnamed node " + id;
        this.model = model;
    }

    public static void resetCount() {
        count = 0;
    }

    public String getName() {
        return name;
    }

    public Icon getIcon() {
        return icon;
    }

    public Model getModel() {
        return model;
    }

    public void setName(String name) {
        this.name = name;
    }

    public abstract void processRequest(Request request);

    public int getId() {
        return id;
    }

    public abstract void validate() throws InvalidModelException;

    public abstract JDialog getPropertiesDialog();

    public static enum NodeType {

        SOURCE_EXPONENTIAL,
        SOURCE_ERLANG,
        SOURCE_UNIFORM,
        SOURCE_CONSTANT,
        SOURCE_DISCRETE,
        SERVER_SIMPLE,
        SERVER_PRIORITY,
        SERVER_QUANTUM,
        BUFFER_QUEUE,
        BUFFER_STACK,
        BUFFER_PRIORITY,
        BUFFER_RANDOM,
        COND_SERVED,
        COND_SERVERS,
        COND_RANDOM,
        MISC_ANCHOR,
        MISC_PRIOR,
        MISC_EXIT
    }
}
